<?php

namespace app\common\huobi;

use EasyExchange\Huobi\Application;
use EasyExchange\Factory;
use think\facade\Env;

class Ticker
{

    protected $app = '';

    protected function initialize(){
        $config = [
            'huobi' => [
                'response_type' => 'array',
                'base_uri' => 'https://api.huobi.pro',
                'app_key' => Env::get('huobi.ACCESS_KEY', ''),
                'secret' => Env::get('huobi.SECRET_KEY', ''),
                'proxy' => [
                    'http' => 'socks5h://127.0.0.1:1080', // Use this proxy with "http"
                    'https' => 'socks5h://127.0.0.1:1080', // Use this proxy with "https"
                    'no' => ['.mit.edu', 'foo.com'],   // Don't use a proxy with these
                ],
                'websocket' => [
                    'base_uri' => [
                        [
                            'url' => 'ws://api.huobi.pro/ws',
                            'type' => 'public',
                        ],
                        [
                            'url' => 'ws://api.huobi.pro/ws/v2',
                            'type' => 'private',
                        ]
                    ],
                    'listen_ip' => '127.0.0.1', // listen ip
                    'listen_port' => 2207, // listen port
                    'heartbeat_time' => 20, // Heartbeat detection time, seconds
                    'timer_time' => 3, // Scheduled task time，seconds
                    'max_size' => 100, // Data retention，1～1000，Data is stored by channel name
                    'data_time' => 1, // Time interval for getting data，seconds
                    'debug' => true,
                ],
                'log' => [
                    'level' => 'debug',
                    'file'  => '/runtime/huobi/exchange.log',
                ],
            ],
        ];

        $this->app =Factory::huobi($config['huobi']);

//        $this->app->basic->systemStatus();

    }

    public function __construct(){
        $this->initialize();
    }

}